<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="ssm" uri="http://ssm.elangzhi.com/jsp/tag/functions" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
Created by GaoXiang
Date: 2018-10-02 23:18:26 星期二
Version: 1.0
手持机用户编辑页面
--%>

<div class="portlet light" >
    <div class="portlet-body form">
        <!-- BEGIN FORM-->
        <form action="#" class="form-horizontal" id="edit-module">
            <div class="form-body">

                <div class="row">
                    <div class="col-md-6 hide">
                        <div class="form-group">
                            <label class="control-label col-md-3">ID</label>
                            <div class="col-md-9">
                                <input type="text" class="form-control" name="id" value="${data.id}" placeholder="默认生成，ID">
                            </div>
                        </div>
                    </div>


                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-md-3">停车场名称</label>
                            <div class="col-md-9">
                                <%--<input type="text" class="form-control" required name="parkName" value="${data.parkName}" placeholder="停车场名称">--%>
                                    <select class="form-control" required name="parkId" id="parkName">
                                        <option value="">选择停车场</option>
                                        <c:forEach var="parkList" items="${parkList}">
                                            <option value="${parkList.id}"<c:if test="${parkList.id == data.parkId}">selected</c:if>>${parkList.name}</option>
                                        </c:forEach>
                                    </select>
                            </div>
                        </div>
                    </div>

                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-md-3">POS用户名</label>
                            <div class="col-md-9">
                                <input type="text" class="form-control" required name="posUserName" value="${data.posUserName}" placeholder="POS用户名">
                            </div>
                        </div>
                    </div>

                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-md-3">在线状态</label>
                            <div class="col-md-9">
                                <%--<input type="text" class="form-control" required name="onlineStatus" value="${data.onlineStatus}" placeholder="在线状态">--%>
                                <select class="form-control" required name="onlineStatus" >
                                    <option value="0"<c:if test="${data.onlineStatus == 0}">selected</c:if>>在线</option>
                                    <option value="1"<c:if test="${data.onlineStatus == 1}">selected</c:if>>不在线</option>
                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-md-3">用户身份</label>
                            <div class="col-md-9">
                                <%--<input type="text" class="form-control" required name="posUserType" value="${data.posUserType}" placeholder="用户身份">--%>
                                <select class="form-control" required name="posUserType" >
                                    <option value="">选择身份</option>
                                    <option value="0"<c:if test="${data.posUserType == 0}">selected</c:if>>收费员</option>
                                    <option value="1"<c:if test="${data.posUserType == 1}">selected</c:if>>管理员</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-actions">
                <div class="row">
                    <div class="col-md-6">
                        <div class="row">
                            <div class="col-md-offset-3 col-md-9">
                                <button type="button" class="btn green" onclick="edit();">修改手持机用户</button>
                                <button type="button" class="btn default" onclick="layer.close(layer_editModule);">取消</button>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6"> </div>
                </div>
            </div>
        </form>
        <!-- END FORM-->
    </div>
</div>
<!-- script 开始 -->
<script>

    $(function(){
        //初始化页面
        initPage();
    });

    /**
     * 保存编辑的手持机用户
     */
    function edit(){
        var param = tools.formParams("edit-module");
        var parkName = $('#parkName  option:selected').text();
        param["parkName"] = parkName;
        if(tools.valid("edit-module")){
            console.log(param);
            tools.post("/posUser/update",param,function(data){
                if(data.success){
                    layer.msg(data.message, {icon: 1,time:1000},function(){
                        //刷新列表页面
                        toPage(null);
                        //关闭弹窗
                        layer.close(layer_editModule);
                    });
                }else{
                    tools.errorTip(data.code,data.message);
                }
            });
        }
    }
</script>
<!-- script 结束 -->